
# 使用字典保存所有模式，方便验证
AC_MODES = {
    "COOL": 1,  # 制冷
    "HEAT": 2,  # 制热
    "FAN": 3,  # 送风
    "AUTO": 4,  # 自动
    "DRY": 5,  # 除湿
}
FAN_SPEED = {
    "LOW": 1,
    "MID": 2,
    "HIGH": 3,
    "AUTO": 4
}


class AcStatus:
    def __init__(self):
        self.power = False
        self._mode = AC_MODES["AUTO"]
        self._temp = 25  # 温度 使用私有变量存储校验温度
        self._fan = FAN_SPEED["AUTO"]
        self.swing = False  # 扫风开关
        self.light = True  # 显示屏灯光
        self.turbo = False  # 强力模式
        self.sleep = False  # 睡眠模式

    @property
    def mode(self):
        return self._mode

    @mode.setter
    def mode(self, value):
        if value not in AC_MODES:
            raise ValueError(f"Invalid mode. AC_MODES={AC_MODES}")
        self._mode = value

    @property
    def fan(self):
        return self._fan

    @fan.setter
    def fan(self, value):
        if value not in FAN_SPEED:
            raise ValueError(f"Invalid mode. FAN_SPEED={FAN_SPEED}")
        self._fan = value

    @property
    def temp(self):
        return self._temp

    @temp.setter
    def temp(self, value):
        if not isinstance(value, int) or not 16 <= value <= 30:
            raise ValueError("Temperature must be an integer between 16 and 30")
        self._temp = value

    # 添加一个方便打印对象内容的方法
    def __str__(self):
        return (f"AcStatus(power={self.power}, mode={self.mode}, "
                f"temp={self.temp}, fan={self.fan}, swing={self.swing}, "
                f"light={self.light}, turbo={self.turbo}, sleep={self.sleep})")


if __name__ == '__main__':
    ac = AcStatus()
    ac.temp = 23
    ac.fan = 78
    print(ac)